 //
//  YKFarmMotifyController.m
//  YK_BaseMediator
//
//  Created by edward on 2021/3/11.
//  Copyright © 2021 Edward. All rights reserved.
//

#import "YKFarmMotifyController.h"
#import <Masonry/Masonry.h>
#import <YK_ExectionModel/YKNSObjectCore.h>
#import <YK_ExectionModel/YKUIKitCore.h>


@interface YKFarmMotifyController ()
///
@property(nonatomic,copy) void(^comfirmBlock)(NSString *detail);

///
@property(nonatomic,strong) UITextView *textView;
/***/
@property (nonatomic, strong) UIButton * comfirmButton;
@end

@implementation YKFarmMotifyController

- (instancetype)initWithdetail:(NSString *)detail block:(void(^)(NSString *detail))block {
    self = [super init];
    if (self) {
        self.comfirmBlock = block;
        self.textView.text = detail;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view addSubview:self.textView];
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
//       make.top.mas_equalTo
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(KTOP_MARGIN + 15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(200);
    }];
    [self.view addSubview:self.comfirmButton];
    [self.comfirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.textView.mas_bottom).offset(15);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(50);
        make.centerX.mas_equalTo(self.view.mas_centerX);
    }];
}

- (UITextView *)textView
{
    if (!_textView) {
        _textView = [[UITextView alloc] init];
        if (@available(iOS 13.0, *)) {
            _textView.yk_borderColor(UIColor.lightGrayColor);
        } else {
            _textView.yk_borderColor(UIColor.blackColor);
        }
        _textView.yk_raduis(8);
        _textView.font = [UIFont systemFontOfSize:20];
    }
    return _textView;
}

- (UIButton *)comfirmButton
{
    if (!_comfirmButton) {
        _comfirmButton = [UIButton buttonWithType:UIButtonTypeSystem];
//        [_comfirmButton setImage:UIColor.blueColor.image forState:UIControlStateNormal];
        _comfirmButton.backgroundColor = [UIColor yk_colorWithHexString:@"#FFB30B"];
        [_comfirmButton setTitle:@"保存" forState:UIControlStateNormal];
        @weakify(self);
        [[_comfirmButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            if (self.comfirmBlock) {
                self.comfirmBlock(self.textView.text);
            }
            [self.navigationController popViewControllerAnimated:YES];
        }];
    }
    return _comfirmButton;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
